package com.example.zhangxinying.smratchatnew;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

/**
 * Created by zhangxinying on 16/9/12.
 */
public class TuangouDetailAdapter extends RecyclerView.Adapter<TuangouDetailAdapter.ViewHolder>{
    private List<TuangouDetailBean> mylist=null;
    private Context mContex=null;


    public TuangouDetailAdapter(Context context,List<TuangouDetailBean> mylist){
        this.mContex=context;
        this.mylist=mylist;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ViewHolder  viewHolder;
        viewHolder=new ViewHolder(LayoutInflater.from(mContex).inflate
                (R.layout.recycler_item_tuangou,null,false));
        return  viewHolder;
    }

    @Override
    public void onBindViewHolder(TuangouDetailAdapter.ViewHolder holder, int position) {
        holder.text_recycler_item_dp_title.setText(mylist.get(position).getTuanName());
        holder.text_recycler_item_dp_origin_price.setText(mylist.get(position).getTuanOriginPrice());
        holder.text_recycler_item_dp_discount_price.setText(mylist.get(position).getTuanDicoutPrice());
        holder.text_recycler_item_dp_sellnum.setText(mylist.get(position).getTuanNumberSell());
    }

    @Override
    public int getItemCount() {
        int count=(this.mylist==null?0:this.mylist.size());
        return count;
    }


    class ViewHolder extends RecyclerView.ViewHolder {
        TextView text_recycler_item_dp_origin_price,text_recycler_item_dp_discount_price,
                text_recycler_item_dp_title,text_recycler_item_dp_sellnum;
        public ViewHolder(View itemView) {
            super(itemView);
            text_recycler_item_dp_title=(TextView)itemView.findViewById(R.id.tv_name_tuangou);
            text_recycler_item_dp_origin_price=(TextView)itemView.findViewById(R.id.tv_name_original);
            text_recycler_item_dp_discount_price=(TextView)itemView.findViewById(R.id.tv_name_discount);
            text_recycler_item_dp_sellnum=(TextView)itemView.findViewById(R.id.tv_recycler_item_sum_sold);
        }
    }
}
